/*============================================================================*/
/*                     		PANTERS_CUCEI	   		                          */
/*============================================================================*/
/*                        OBJECT SPECIFICATION                                */
/*============================================================================*
* C Source:        main.c
* version:         1.0 
* created_by:      Panters  team 
* date_created:    Oct 1 2013 
*=============================================================================*/
/* DESCRIPTION : C source for ADC management                             */
/*============================================================================*/
/* FUNCTION COMMENT : This file reffer to the main                            */
/*                                                                            */
/*============================================================================*/
/*                               OBJECT HISTORY                               */
/*============================================================================*/
/*  REVISION |   DATE      |                               |      AUTHOR      */
/*----------------------------------------------------------------------------*/
/*  1.0      | 1/10/2013  |                               | PANTERS_CUCEI    */
/* First version of this source                                               */
/*============================================================================*/

/* Includes */
#include "derivative.h" /* include peripheral declarations */
#include "mcl\CrystalClock.h"
#include "mcl\ARM_SysTick.h"
#include "gsc_scheduler\gsc_sch_core\gsc_sch_core_intf.h"
#include "SCR\IO_ports.h"
/* -------- */



/*==================================================*/ 
/* Definition of RAM variables                         */
/*==================================================*/
volatile unsigned int sys_tick_counter = 0;
volatile unsigned char AnalogCamera[128];
volatile unsigned char DigitalCamera[128];

volatile unsigned char center=0;
volatile unsigned char K=0;
extern volatile float LM=30,RM=30;
volatile short int Error=0;


/*==================================================*/

/*======================================================*/ 
/* functions prototypes                  */
/*======================================================*/
void WatchDog_cfg(void);
/*======================================================*/


/**************************************************************
 *  Name                 : main
 *  Description          : main for all scheduler
 *  Parameters           :  
 *  Return               :
 *  Critical/explanation :    
 **************************************************************/
int main (void)
{
	
	//int i=0;
	
	/* Disable Watch Dog */
	WatchDog_cfg();
	/* Initialise clock system for 48 MHz */
	InitClock(); 
	/* Configure the timer and the interrupt to be used to generate the tick of the scheduler */
	InitSysTick();
	/* Scheduler Initialisation and tasks initialisation  */
	gsc_sch_core_Init();
	/* Execute Scheduler */

	for(;;)
	{
	
		/*Wait to start the scheduller*/
		if(TFC_PUSH_BUTTON_0_PRESSED)
		{
			/* Execute Scheduler */
			gsc_sch_core_exec();
		}
		
	}

	return 0;
}

 
 /*
  * Init watch dog
  */
 void WatchDog_cfg(void)
 {
	 /* Disable watch dog */
	 SIM_COPC |= SIM_COPC_COPT(0);
 }
 
 void SysTick_Handler(void)
 {
 	sys_tick_counter++;
 	gsc_sch_core_tick_isr();
 }

